package chapter1.fundamentals.exercise;

import edu.princeton.cs.algs4.StdRandom;

import java.lang.reflect.Array;

/**
 * @author quanlinlin on 2018/10/25 20:40.
 * @version 1.0
 */
public class E_11 {

    public static void main(String[] args) {
        boolean[][] randomArray = getRandomArray();
        solution(randomArray);

    }

    public static boolean[][] getRandomArray() {
        int length = StdRandom.uniform(3, 10);
        int dep = StdRandom.uniform(3, 10);
        boolean[][] b = new boolean[dep][length];
        for (int i = 0; i < dep; i++) {
            for (int j = 0; j < length; j++) {
                b[i][j] = StdRandom.bernoulli(0.6);
            }
        }
        return b;
    }

    public static void solution(boolean[][] b) {
        for (int i = 0; i < b[0].length; i++) {
            System.out.print(i);
        }
        System.out.println();
        for (int i = 0; i < b.length; i++) {
            System.out.print(i + 1);
            for (int j = 0; j < b[i].length; j++) {
                boolean value = b[i][j];
                getSymbol(value);
            }
            System.out.println("|");
        }
        Array.getLength(b);
    }

    private static void getSymbol(boolean value) {
        if (value) {
            System.out.print("*");
        } else {
            System.out.print(" ");
        }
    }
}
